1213A - Chips Moving - CodeForces Solution


math *900

Please click on ads to support us..

Python Code:

n = int(input())
a = list(map(int, input().split()))
odds = 0
evens = 0
for i in range(n):
    if a[i] % 2 == 0:
        evens += 1
    else:
        odds += 1
print(min(odds, evens))

C++ Code:

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int even = 0, odd = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      even++;
    } else {
      odd++;
    }
  }
  cout << min(even, odd) << endl;
  return 0;
}


Comments

Submit
0 Comments
More Questions

645A - Amity Assessment
1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array
366A - Dima and Guards
716B - Complete the Word
1461C - Random Events
1627A - Not Shading
141B - Hopscotch
47B - Coins
1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman